﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Housing;

public partial class PublicContent_UpdatePassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserId"] != null)
        {
            lblusername.Text = Session["UserName"].ToString();
        }
        else
            WebHelper.AlertAndRedirect("登陆超时，请重新登陆", "../Login.aspx");
        
    }
    protected void btnupdate_Click(object sender, EventArgs e)
    {
        Users user = new Users(lblusername.Text);
        if (user.Password!=null)
        {
            if (txboldpwd.Text != user.Password)
                WebHelper.Alert("原始密码输入错误！");
            else
            {
                user.Password = txbnewpwd.Text;
                bool succ = user.UpdateAUser(user); ;
                if (succ)
                    WebHelper.Alert("密码修改成功！");
                else
                    WebHelper.Alert("密码未修改，请重新操作！");
            }
        }
    }
}
